/*
 * Copyright 2007 Matt Jensen
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.jtell.internal;

import org.jtell.EventSink;

import java.util.Set;

/**
 * <p>
 * <code>EventSinkAffinityMap</code> defines the public interface to an event sink affinity map. Event sink affinity
 * maps hold associations between event and source classes and {@link EventSink} instances which have been associated
 * with those classes. Implementations must handle polymorphic class relationships correctly; that is, if an event sink
 * is associated with {@link Number}, then it must be returned for queries on {@link Integer} as well.  
 * </p>
 */
public interface EventSinkAffinityMultiMap
{
    /**
     * <p>
     * Clear all entries from the map. 
     * </p>
     */
    void clear();

    /**
     * <p>
     * Get all event sinks which have been associated with a given event class <em>or any of its subclasses</em>.
     * </p>
     * 
     * @param eventClassName the fully qualified name of the event class.
     * @return {@link Set} of {@link EventSink} instances.
     */
    Set<EventSink> getAllForEventClass(String eventClassName);

    /**
     * <p>
     * Get all event sinks which have been associated with a given source class <em>or any of its subclasses</em>.
     * </p>
     *
     * @param sourceClassName the fully qualified name of the source class.
     * @return {@link Set} of {@link EventSink} instances.
     */
    Set<EventSink> getAllForSourceClass(String sourceClassName);

    /**
     * <p>
     * Associate an event sink with an event class.
     * </p>
     *
     * @param eventClassName the fully qualified name of the event class.
     * @param eventSink the event sink.
     */
    void putForEventClass(String eventClassName, EventSink eventSink);

    /**
     * <p>
     * Associate an event sink with a source class.
     * </p>
     *
     * @param sourceClassName the fully qualified name of the source class.
     * @param eventSink the event sink.
     */
    void putForSourceClass(String sourceClassName, EventSink eventSink);

    /**
     * <p>
     * Remove all event sinks which match a given predicate.
     * </p>
     *
     * @param predicate the matching predicate.
     */
    void removeMatching(Predicate<EventSink> predicate);
}
